{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">投票统计</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <form class="layui-form layui-form-pane" action="{:url('admin/luntan_votecount/index')}" method="get">
                   <!--  <div class="layui-inline">
                        <label class="layui-form-label">投票名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="votename" value="{$votename}" placeholder="请输入投票名称" class="layui-input">
                        </div>
                    </div> -->
                     <div class="layui-inline">
                        <label class="layui-form-label">开始时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="start_time" value="{$start_time}" class="layui-input datetime">
                        </div>
                    </div>
                     <div class="layui-inline">
                        <label class="layui-form-label">结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="end_time" value="{$end_time}" class="layui-input datetime">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn">搜索</button>
                    </div>
                </form>
                <hr>
                <form action="" method="post" class="ajax-form">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th style="width: 30px;">ID</th>
                        <th>栏目名称</th>
                        <th>投票名称</th>
                        <th>选项</th>
                        <th>票数</th>
                        <th>百分比</th>
                    </tr>
                    </thead>
                    <tbody>
                        {foreach name="list" item="vo"}
                           {foreach name="vo" item="val"}
                                <tr>
                                    <td>1</td>
                                    <td>{$val['categoryname']}</td>
                                    <td>{$val['votename']}</td>
                                    <td>{$val['selectname']}</td>
                                    <td>{$val['count']}</td>
                                    <td>{$val['percent']}</td>
                                </tr>
                           {/foreach}
                        {/foreach}
                    </tbody>
                </table>
                <!--分页-->

                </form>
            </div>
        </div>
    </div>
</div>
<script src="/static/js/jquery.min.js"></script>
<script type="text/javascript">
    function p(s) {
        return s < 10 ? '0' + s: s;
    }

    var myDate = new Date();
    //获取当前年
    var year=myDate.getFullYear();
    //获取当前月
    var month=myDate.getMonth()+1;
    //获取当前日
    var date=myDate.getDate(); 
    var h=myDate.getHours();       //获取当前小时数(0-23)
    var m=myDate.getMinutes();     //获取当前分钟数(0-59)
    var s=myDate.getSeconds();  
    var now=year+'-'+p(month)+"-"+p(date)+" "+p(h)+':'+p(m)+":"+p(s);

    // var timestamp = Date.parse(new Date());
    // console.log(timestamp);
    // var timestamp1 = timestamp - 3600*24*1*1000;
    // console.log(timestamp1);
    // var endtime = getMyDate(timestamp1);
    // console.log(endtime);

    $(function(){
        $(".cclick").click(function(){
            //获得当前时间戳
            var timestamp = Date.parse(new Date());
            var day = $(this).attr("data-number");
            var timestamp1 = timestamp - 3600*24*1000*day;
            var endtime = getMyDate(timestamp1);
            $(this).parents("form").find("input[name=start_time]").val(endtime);
            $("input[name=end_time]").val(now);

        })          
    });

    //将时间戳转化日期
     function getMyDate(str){  
            var oDate = new Date(str),  
            oYear = oDate.getFullYear(),  
            oMonth = oDate.getMonth()+1,  
            oDay = oDate.getDate(),  
            oHour = oDate.getHours(),  
            oMin = oDate.getMinutes(),  
            oSen = oDate.getSeconds(),  
            oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间  
            return oTime;  
        }; 
        //补0操作
      function getzf(num){  
          if(parseInt(num) < 10){  
              num = '0'+num;  
          }  
          return num;  
      }
</script>
{/block}